package com.e.ego.dialog

import android.content.Context
import android.graphics.drawable.ColorDrawable
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import android.widget.PopupWindow

/**
 * Created by lxy on 2016/8/24 22:17.
 */
abstract class EPopup(context: Context) : PopupWindow(context) {

    init {
        val view = LayoutInflater.from(context).inflate(layout(), null)
        this.contentView = view
        this.width = LinearLayout.LayoutParams.WRAP_CONTENT
        this.height = LinearLayout.LayoutParams.WRAP_CONTENT
        this.isFocusable = true
        this.isOutsideTouchable = true
        this.setBackgroundDrawable(ColorDrawable(0))

        onPopupCreated(context)
    }

    protected  abstract fun layout(): Int
    protected  abstract fun onPopupCreated(context: Context)
    abstract fun showPopup(parent: View)

}
